#include"../source/socket.hpp"
#include<cstdio>

int main(){
    Socket lst_sock;
    lst_sock.CreateServer(8888);
    while(1){
        int newfd = lst_sock.Accept();
        if(newfd < 0) continue;  
        Socket client_sock(newfd);

        char buf[1024];
        int ret = client_sock.Recv(buf,1023);
        buf[ret] = '\0';
        printf("%s\n",buf);
        if(ret<0){
            client_sock.Close();
            continue;  
        }
        client_sock.Send(buf,ret);
        client_sock.Close();
    }
    lst_sock.Close();
}